package com.chenyun.common.utils;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.extra.mail.MailUtil;

import java.io.File;
import java.util.List;

/**
 * 发送邮件  调用hutool工具
 * @author: Lonni
 * @date: 2022/2/18 0018 14:05
 */
public class MailUtils {

    /**
     * 发送邮件
     * @param toMail
     * @param subject
     * @param content
     */
    public static void sendMail(String toMail,String subject,String content,List<File> files){
        if (CollectionUtil.isNotEmpty(files)){
            MailUtil.send(toMail,subject,content,false,files.toArray(new File[]{}));
        }else {
            MailUtil.send(toMail,subject,content,false);
        }

    }
    public static void sendMail(List<String> toMails, String subject, String content,List<File> files){
        if (CollectionUtil.isNotEmpty(files)){
            MailUtil.send(toMails,subject,content,false,files.toArray(new File[]{}));
        }else {
            MailUtil.send(toMails,subject,content,false);
        }
    }





}
